﻿using System;
using System.Collections.Generic;
using System.Web;
using FTchina;
namespace FTchina.Api
{
    /// <summary>
    ///userselecter 的摘要说明
    /// </summary>
    public class userselecter
    {
        public userselecter()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }
        #region 人员部门信息格式化

        /// <summary>
        /// 获取5|行政部类似的格式化信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string GetFormatNameById(string id)
        {
            return id + "|" + shujuku.GetValueByKey("master_name", "userlist", "id='" + id + "'");
        }


        /// <summary>
        /// 通过id获取组织架构名称
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string GetNameById(string id)
        {
            return shujuku.GetValueByKey("master_name", "userlist", "id='" + id + "'");
        }



        /// <summary>
        /// 输入字符串组，只返回id （"11|王二,13|魏宝辉,"  返回11,13）
        /// </summary>
        /// <param name="idnames">11|王二,13|魏宝辉,</param>
        /// <returns></returns>
        public static string DelName(string idnames)
        {

            string temp = string.Empty;
            if (idnames.Length > 0)
            {
                idnames = idnames.Substring(0, idnames.Length - 1);//去掉最后的逗号
                if (idnames.Contains(","))
                {//含有多个子项
                    foreach (string str in idnames.Split(','))
                    {
                        temp += str.Split('|')[0] + ",";
                    }
                    temp = temp.Substring(0, temp.Length - 1);

                }
                else
                {//只有一个子项
                    temp = idnames.Split('|')[0];
                }
            }

            return temp;
        }




        /// <summary>
        /// 通过ids来获取用户名，如11,13获取 王二,魏宝辉
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public static string GetNamesByIds(string ids)
        {
            string temp = string.Empty;
            if (ids.Length > 0)
            {

                if (ids.Contains(","))
                {//含有多个子项
                    foreach (string str in ids.Split(','))
                    {
                        temp += GetFormatNameById(str) + ",";
                    }
                }
                else
                {//只有一个子项
                    temp = GetFormatNameById(ids) + ",";//最后添加一个逗号，跟userselecter保持返回数据一致。
                }
            }
            return temp;
        }

        #endregion



        #region 通过部门id获取部门下所有员工id

        /// <summary>
        /// 通过部门id获取部门下所有员工id
        /// </summary>
        /// <param name="bumenid"></param>
        /// <returns></returns>
        public static string GetSingllsByBumenID(string bumenid)
        {
            string temp = string.Empty;

            return temp;

        }
        #endregion
    }
}